package org.electrode.base;

import edu.wpi.first.wpilibj.DigitalModule;
import edu.wpi.first.wpilibj.buttons.Button;

/**
 * 
 * @author scheuerg
 */
public class LimitSwitch extends Button {
	final int port;
	final DigitalModule module;

	public LimitSwitch(int port) {
		this.port = port;
		module = DigitalModule.getInstance(DigitalModule
				.getDefaultDigitalModule());
		if (!module.allocateDIO(port, true)) {
			throw new IllegalStateException("Port already allocated");
		}
	}

	public boolean get() {
		return !module.getDIO(port);
	}

}
